const download = require('download-git-repo');
const ora = require('ora');
const log = require('../utils/log');



function clone(git, destDir,name='mini-app') {
  log.msg(git);
  let spinner = ora(`downloading ${name}...`)
  spinner.start();
  return new Promise((resolve, reject) => {
    // download('direct:git@git.365mbb.com:html/mini_weddingDress.git', dest, { clone: true }, function (err) {
    download(`direct:${git}`, destDir, { clone: true }, function (err) {
      spinner.stop();
      if (err) {
        log.error(err);
        process.exit()
      } else {
        log.success('clone success...');
        resolve();
      }
    })
  })
}

module.exports = clone